// 2种方式定义一个数组（数组中的元素可以是任意类型）
let a: number[]
let list: Array<number> = [1, 2, 3];

function fun(arr:number[])
{   
    let a:number=0
    for (var i = 0; i < arr.length; i++)
    {
        a+=arr[i]
    }
    console.log(a);
    
}
fun([2,8,9,6,5,8,7])

function fun1(a:any)
{
    if (Boolean(a))
    {
        console.log(true);
        
    } else
    {
        console.log(false);
        
    }
}
fun1("nudefined")


function fun2(arr:any)
{
    let a:number[]=[]
    for (var i = 0; i < arr.length; i++)
    {
        if (typeof(arr[i])=="number")
        {
           
            a.push(arr[i]*5)
        }
    }
    console.log(a);
    
}
fun2(["a","c",6,"e",5,3,"d"])

function fun3(arr:number[])
{
    let a: number[] = [0]
    for (var i = 0; i < arr.length; i++)
    {
       
            a.push(arr[i])
        
    }
    console.log(a);
   
}
fun3([1,2,3,4,5,6])

function bouncer(arr:any)
{   
    let a:number[] = []
    for (var i = 0; i < arr.length; i++)
    {
        if (Boolean(arr[i]))
        {
            a.push(arr[i])
        }
    }
    console.log(a);
    
}
bouncer([7,"","qq",false,9])

function str(arr:string)
{
    for (var i = 0; i < arr.length; i++)
    {
        for (var j = i+1; j < arr.length; j++)
        {
            if (arr[i] == arr[j])
            {
                console.log(arr[i]);
                
            }
        }
    }
}
str("2222222222222")